package com.zimin.cloud.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zimin.cloud.mine.pojo.system.view.MenuVO;
import com.zimin.cloud.system.pojo.entity.Menu;
import com.zimin.cloud.system.mapper.MenuMapper;
import com.zimin.cloud.system.service.IMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 菜单权限 服务实现类
 * </p>
 *
 * @author zimin
 * @since 2021-12-30 11:05
 */
@Service("menuService")
@Slf4j
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<MenuVO> listVO(Wrapper<Menu> wrappers) {
        return menuMapper.selectList(wrappers, MenuVO.class);
    }

    @Override
    public List<MenuVO> getMenuPermissionsByRoleIds(Set<String> roleIds) {
        var queryWrapper = new QueryWrapper<>();
        queryWrapper.in("role.id",roleIds);
        return menuMapper.getMenuPermissionsByRoleIds(queryWrapper);
    }
}
